#pragma once

#include "scubserver.h"
#include "Method.h"
#include<vector>

struct SubmarineOptions
{
	bool m_bNoHeading;
	bool m_bReport;
	bool m_bListOnly;
	bool m_bModeQuiet;
	bool m_bNoNumbering;

	bool m_bComplexity;
	bool m_bCalls;
	bool m_bReturns;
	bool m_bDataUse;

	SubmarineOptions()
	{
		m_bNoHeading = false;
		m_bReport = false;
		m_bListOnly = false;
		m_bModeQuiet = false;
		m_bNoNumbering = false;

		m_bDataUse = false;
		m_bCalls = false;
		m_bReturns = false;
		m_bComplexity = true; //default
	}
};

struct Funcalyzer :
    public Scubserver
{
public:
	//private:
    std::vector<Method*> m_apxMethod;
    Scope* m_pxCurrentScope;
    Method * m_pxMethod;
    int m_nDepthMax;

	int m_nSerialNumber;
	int m_nLineNumber;

	bool		m_bInsideFunction;
	bool		m_bFuncDefActive;
    bool		m_bReturnActive;
    bool		m_bFuncCallActive;
    std::string	m_sFuncCall;

private:
    void onEntryParen(Scope& inOldScope);
    void onEntryBlock(Scope& inOldScope);
    void onEntryComment(Scope& inOldScope);
    void gatherParameters(Scope& inOldScope);

public:
    virtual void onNewToken(Scope& inScope, Token& inToken);
    virtual void onScopeEntry(Scope& inNewScope, Scope& inOldScope);
    virtual void onScopeExit(Scope& inNewScope, Scope& inOldScope);
	virtual void setScope(Scope& inScope)
	{
		m_pxCurrentScope = &inScope;
	}
	void print(SubmarineOptions* pxOpt);

	void outputReturns(SubmarineOptions* pxOpt);
    void outputCalls(SubmarineOptions* pxOpt);
	void outputDataUsage(SubmarineOptions* pxOpt);
	void outputComplexity(SubmarineOptions* pxOpt);

    Funcalyzer(void);
    ~Funcalyzer(void);
};
